//
//  FirstPageMiddleView.m
//  CoachsBook
//
//  Created by MaBookPro on 2022/8/9.
//

#import "FirstPageMiddleView.h"

@implementation FirstPageMiddleView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self CreateUI];
    }
    return self;
}
-(void)CreateUI{
    
    
    UIView *backV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, 460)];
    backV.backgroundColor = [UIColor whiteColor];
    backV.userInteractionEnabled = YES;
    [self addSubview:backV];
    
    
    UIButton *picTitleBtn = [[UIButton alloc]initWithFrame:CGRectMake(15, 10, APPwidth/2-20, 140)];
    [picTitleBtn setTitle:@"招生图文" forState:0];
    picTitleBtn.titleLabel.textAlignment = 1;
    picTitleBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [picTitleBtn setTitleColor:[UIColor orangeColor] forState:0];
    picTitleBtn.layer.cornerRadius = 5;
    picTitleBtn.layer.borderColor = [UIColor orangeColor].CGColor;
    picTitleBtn.layer.borderWidth = 1;
    [backV addSubview:picTitleBtn];
    
    
    UIButton *awardCertificateBtn = [[UIButton alloc]initWithFrame:CGRectMake(APPwidth/2+5, 10, APPwidth/2-20, 65)];
    [awardCertificateBtn setTitle:@"颁发奖状" forState:0];
    awardCertificateBtn.titleLabel.textAlignment = 1;
    awardCertificateBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [awardCertificateBtn setTitleColor:[UIColor orangeColor] forState:0];
    awardCertificateBtn.layer.cornerRadius = 5;
    awardCertificateBtn.layer.borderColor = [UIColor orangeColor].CGColor;
    awardCertificateBtn.layer.borderWidth = 1;
    [backV addSubview:awardCertificateBtn];
    
    UIButton *teachingStyleBtn = [[UIButton alloc]initWithFrame:CGRectMake(APPwidth/2+5, awardCertificateBtn.frame.size.height+awardCertificateBtn.frame.origin.y+10, APPwidth/2-20, 65)];
    [teachingStyleBtn setTitle:@"教学风采" forState:0];
    teachingStyleBtn.titleLabel.textAlignment = 1;
    teachingStyleBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [teachingStyleBtn setTitleColor:[UIColor orangeColor] forState:0];
    teachingStyleBtn.layer.cornerRadius = 5;
    teachingStyleBtn.layer.borderColor = [UIColor orangeColor].CGColor;
    teachingStyleBtn.layer.borderWidth = 1;
    [backV addSubview:teachingStyleBtn];
    
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, picTitleBtn.frame.size.height+picTitleBtn.frame.origin.y+15, APPwidth, 10)];
    line.backgroundColor = rgba(245, 245, 250, 1);
    [backV addSubview:line];
    
    //招生服务
    UIView *myDataLineV = [[UIView alloc]initWithFrame:CGRectMake(15, line.frame.size.height+line.frame.origin.y+15, 3, 15)];
    myDataLineV.backgroundColor = rgba(22, 120, 255, 1);
    myDataLineV.layer.cornerRadius = 2;
    [backV addSubview:myDataLineV];
    UILabel *myDataLab = [[UILabel alloc]initWithFrame:CGRectMake(myDataLineV.frame.size.width+myDataLineV.frame.origin.x+5, line.frame.size.height+line.frame.origin.y+15, 70, 15)];
    myDataLab.text = @"招生服务";
    myDataLab.textColor = [UIColor blackColor];
    myDataLab.textAlignment = 0;
    myDataLab.font = [UIFont systemFontOfSize:16 weight:bold];
    [backV addSubview:myDataLab];
    
    
    NSArray *AdmissionsServicesArr = @[@"招生名片",@"微信头像",@"陪练服务",@"全部服务"];
    NSArray *AdmissionsServicesImg = @[@"AdSIcon",@"AdSIcon-1",@"AdSIcon-2",@"AdSIcon-3"];
    CGFloat btnW = (APPwidth-50)/4;
    CGFloat btnH = 80;
    for (int i = 0; i < AdmissionsServicesArr.count; i++) {
        NSInteger row = i/4;
        NSInteger col = i%4;
        CGFloat btnX = 10 + (btnW + 10 ) * col;
        CGFloat btnY = 10 + (btnH + 10 ) * row;
        
        UIButton *zhaoshengfuwuBtn =[UIButton buttonWithType:UIButtonTypeCustom];
        zhaoshengfuwuBtn.frame = CGRectMake(btnX,btnY+myDataLab.frame.size.height+myDataLab.frame.origin.y+10, btnW, btnH);
        [zhaoshengfuwuBtn setTitle:AdmissionsServicesArr[i] forState:0];
        zhaoshengfuwuBtn.titleLabel.textAlignment = 1;
        zhaoshengfuwuBtn.titleLabel.font = [UIFont systemFontOfSize:13];
        [zhaoshengfuwuBtn setTitleColor:[UIColor orangeColor] forState:0];
        zhaoshengfuwuBtn.layer.cornerRadius = 5;
        zhaoshengfuwuBtn.layer.borderColor = [UIColor orangeColor].CGColor;
        zhaoshengfuwuBtn.layer.borderWidth = 1;
        [zhaoshengfuwuBtn setImage:[UIImage imageNamed:AdmissionsServicesImg[i]] forState:0];
        zhaoshengfuwuBtn.titleLabel.textAlignment = 1;
        zhaoshengfuwuBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [zhaoshengfuwuBtn setTitleColor:[UIColor blackColor] forState:0];
        zhaoshengfuwuBtn.imageEdgeInsets = UIEdgeInsetsMake(-30, 30, 0, 25);
        [zhaoshengfuwuBtn.imageView setContentMode:UIViewContentModeScaleAspectFit];
        zhaoshengfuwuBtn.titleEdgeInsets = UIEdgeInsetsMake(30, -30, 0, 0);
        [backV addSubview:zhaoshengfuwuBtn];
        
        if (i == 0) {
            _admissionsServicesBtn = zhaoshengfuwuBtn;
            [zhaoshengfuwuBtn setBackgroundColor:rgba(255, 248, 242, 1)];
            
        }else if (i == 1){
            _wechatAvatarBtn = zhaoshengfuwuBtn;
            [zhaoshengfuwuBtn setBackgroundColor:rgba(238, 246, 253, 1)];

        }else if (i == 2){
            
            [zhaoshengfuwuBtn setBackgroundColor:rgba(255, 245, 244, 1)];

        }else{
            
            [zhaoshengfuwuBtn setBackgroundColor:rgba(237, 250, 244, 1)];

        }

    }
    UIView *jxglLineV = [[UIView alloc]initWithFrame:CGRectMake(15, _admissionsServicesBtn.frame.size.height+_admissionsServicesBtn.frame.origin.y+15, 3, 15)];
    jxglLineV.backgroundColor = rgba(22, 120, 255, 1);
    jxglLineV.layer.cornerRadius = 2;
    [backV addSubview:jxglLineV];
    UILabel *jxglLab = [[UILabel alloc]initWithFrame:CGRectMake(jxglLineV.frame.size.width+jxglLineV.frame.origin.x+5, _admissionsServicesBtn.frame.size.height+_admissionsServicesBtn.frame.origin.y+15, 70, 15)];
    jxglLab.text = @"教学管理";
    jxglLab.textColor = [UIColor blackColor];
    jxglLab.textAlignment = 0;
    jxglLab.font = [UIFont systemFontOfSize:16 weight:bold];
    [backV addSubview:jxglLab];
    
    NSArray *JxglArr = @[@"模拟成绩",@"预约练车",@"考试安排",@"全部管理"];
    NSArray *JxglImgArr = @[ @"AdSIcon-4",@"AdSIcon-5",@"AdSIcon-6",@"AdSIcon-7"];
    CGFloat jxglW = (APPwidth-50)/4;
    CGFloat jxglH = 80;
    for (int i = 0; i < JxglArr.count; i++) {
        NSInteger row = i/4;
        NSInteger col = i%4;
        CGFloat jxglbtnX = 10 + (jxglW + 10 ) * col;
        CGFloat jxglbtnY = 10 + (jxglH + 10 ) * row;
        
        UIButton *teachingManagementBtn =[UIButton buttonWithType:UIButtonTypeCustom];
        teachingManagementBtn.frame = CGRectMake(jxglbtnX,jxglbtnY+jxglLab.frame.size.height+jxglLab.frame.origin.y+10, btnW, btnH);
        [teachingManagementBtn setTitle:JxglArr[i] forState:0];
        teachingManagementBtn.titleLabel.textAlignment = 1;
        teachingManagementBtn.titleLabel.font = [UIFont systemFontOfSize:13];
        [teachingManagementBtn setTitleColor:[UIColor orangeColor] forState:0];
        teachingManagementBtn.layer.cornerRadius = 5;
        teachingManagementBtn.layer.borderColor = [UIColor orangeColor].CGColor;
        teachingManagementBtn.layer.borderWidth = 1;
        [teachingManagementBtn setImage:[UIImage imageNamed:JxglImgArr[i]] forState:0];
        teachingManagementBtn.titleLabel.textAlignment = 1;
        teachingManagementBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [teachingManagementBtn setTitleColor:[UIColor blackColor] forState:0];
        teachingManagementBtn.imageEdgeInsets = UIEdgeInsetsMake(-30, 30, 0, 25);
        [teachingManagementBtn.imageView setContentMode:UIViewContentModeScaleAspectFit];
        teachingManagementBtn.titleEdgeInsets = UIEdgeInsetsMake(30, -30, 0, 0);
        [backV addSubview:teachingManagementBtn];
        
        if (i == 0) {
            [teachingManagementBtn setBackgroundColor:rgba(238, 246, 253, 1)];

        }else if (i == 1){
            
            [teachingManagementBtn setBackgroundColor:rgba(237, 250, 244, 1)];

        }else if (i == 2){
            
            [teachingManagementBtn setBackgroundColor:rgba(255, 248, 242, 1)];

        }else{
            
            [teachingManagementBtn setBackgroundColor:rgba(255, 245, 244, 1)];

        }

    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(0, backV.frame.size.height-10, APPwidth, 10)];
    line1.backgroundColor = rgba(245, 245, 250, 1);
    [backV addSubview:line1];

    
    
    
    
    
}
@end
